{% extends 'IcsocUIBundle::page.html.twig' %}
{% from 'IcsocUIBundle:Macro:formValidator.html.twig' import jqvalidator %}
{% from 'IcsocUIBundle:Macro:actions.html.twig' import create %}
{% block content %}
    <div class="page-content">

            {% if flag == 'agent' %}
                {{ form_start(form, {'attr':{'id':'validate-form'}}) }}
                    {{ form_row(form.oldPassword) }}
                    {{ form_row(form.agPassword) }}
                    <div class="clearfix form-actions">
                        <div class="col-md-offset-4 col-md-8">
                            <button class="btn btn-info" type="submit">
                                <i class="ace-icon fa fa-check bigger-110"></i>
                                {{ 'Submit'|trans }}
                            </button>
                        </div>
                    </div>
                {{ form_end(form) }}
            {% elseif flag == 'ccod' %}
                {{ form_start(form, {'attr':{'id':'validate-form'}}) }}
                    {{ form_row(form.oldPassword) }}
                    {{ form_row(form.adminPassword) }}
                    <div class="clearfix form-actions">
                        <div class="col-md-offset-4 col-md-8">
                            <button class="btn btn-info" type="submit">
                                <i class="ace-icon fa fa-check bigger-110"></i>
                                {{ 'Submit'|trans }}
                            </button>
                        </div>
                    </div>
                {{ form_end(form) }}
            {% endif %}
    </div>
{% endblock %}
{% block footer %}
    {% javascripts
    '@jqvalidate_js'
    filter='uglifyjs'
    %}
    <script src="{{ asset_url }}"></script>
    {% endjavascripts %}
    <script>
        $('#validate-form').validate({
            {{ jqvalidator() }}
        {% if flag == 'ccod' %}
            rules: {
                'securityCcCcods[oldPassword]': {required:true, remote:{
                    url: '{{ path('icsoc_security_check_pass') }}?flag={{ flag }}',
                    type: 'post',
                    dataType: 'json',
                    data: {
                        old_pass: function () {
                            return $('#securityCcCcods_oldPassword').val();
                        },
                    }
                }},
                'securityCcCcods[adminPassword][first]': {required:true},
                'securityCcCcods[adminPassword][second]': {required:true,equalTo:'#securityCcCcods_adminPassword_first'},
             },
            messages: {
                'securityCcCcods[oldPassword]': {required:'{{ 'The old password can not be empty'|trans }}',remote:'{{ 'The old password is not correct'|trans }}'},
                'securityCcCcods[adminPassword][first]': {'required':'{{ 'Password can not be empty'|trans }}'},
                'securityCcCcods[adminPassword][second]': {'required':'{{ 'Password can not be empty'|trans }}',equalTo:'{{ 'Please re - enter the same value'|trans }}'}
             }
        {% elseif flag == 'agent' %}
            rules: {
                'securityWinAgent[oldPassword]': {required:true, remote:{
                    url: '{{ path('icsoc_security_check_pass') }}?flag={{ flag }}',
                    type: 'post',
                    dataType: 'json',
                    data: {
                        old_pass: function () {
                            return $('#securityWinAgent_oldPassword').val();
                        },
                    }
                }},
                'securityWinAgent[agPassword][first]': {required:true},
                'securityWinAgent[agPassword][second]': {required:true,equalTo:'#securityWinAgent_agPassword_first'},
            },
            messages: {
                'securityWinAgent[oldPassword]': {required:'{{ 'The old password can not be empty'|trans }}',remote:'{{ 'The old password is not correct'|trans }}'},
                'securityWinAgent[agPassword][first]': {'required':'{{ 'Password can not be empty'|trans }}'},
                'securityWinAgent[agPassword][second]': {'required':'{{ 'Password can not be empty'|trans }}',equalTo:'{{ 'Please re - enter the same value'|trans }}'}
            }
        {% endif %}
        });
    </script>
{% endblock %}